#!/usr/bin/env python3
# -*- coding:utf-8 -*-
import configparser

class ReadIni():
    """配置文件"""

    def __init__(self,iniFile):
        self.iniFile=iniFile
        self.ini = configparser.RawConfigParser()  # 当有%的符号时请使用Raw读取
        self.ini.read(self.iniFile, encoding='utf-8')

    def get(self, section, option):
        """获取"""
        return self.ini.get(section, option)

    def set(self, section, option, value):
        """更新"""
        self.ini.set(section, option, value)
        with open(self.iniFile, 'w') as f:
            self.ini.write(f)

    @property
    def base_url(self):
        return self.get('website', 'base_url')

    @property
    def username(self):
        return self.get('website', 'username')

    @property
    def password(self):
        return self.get('website', 'password')
